﻿#include "Composite.h"
#include <QDebug>

Composite::Composite(QString name) : Component(name)
{

}

//void Composite::Add(Component *c)
//{
//    m_children.append(c);
//}

//void Composite::Remove(Component *c)
//{
//    m_children.removeOne(c);
//}

void Composite::Add(const shared_ptr<Component> &c)
{
    m_children.append(c);
}

void Composite::Remove(const shared_ptr<Component> &c)
{
    m_children.removeOne(c);
}

void Composite::Display(int depth)
{
    qDebug() << QString(depth, '-') << QString(" %1").arg(m_name);

    for (int i = 0; i < m_children.size(); i++) {
        m_children[i]->Display(depth + 2);
    }
}
